<?php

namespace App\Http\Controllers\Agency;

use App\Http\Controllers\Controller;
use App\Services\DynamicService;
use Illuminate\Http\Request;
use hg\apidoc\annotation as Apidoc;

/**
 * 动态广场
 * @Apidoc\Group("market")
 */

class DynamicController extends Controller
{
    /**
     * @Apidoc\Title ("客户详情-更新动态状态")
     * @Apidoc\Url("/agency/dynamicStatusUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("ids",type="int",require=true,desc="动态列表id")
     * @Apidoc\Param("status",type="string",require=true,desc="wait待审核；pass通过；refuse未通过")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function dynamicStatusUpdate(Request $request ,DynamicService $dynamicService)
    {
        $params = $request->input();
        $result = $dynamicService->updateDynamicStatus($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("客户详情-删除动态")
     * @Apidoc\Url("/agency/dynamicDel")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("ids",type="int",require=true,desc="动态列表id")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function dynamicDel(Request $request ,DynamicService $dynamicService)
    {
        $params = $request->input();
        $result = $dynamicService->dynamicDel($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("客户详情-更新评论状态")
     * @Apidoc\Url("/agency/commentStatusUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("ids",type="int",require=true,desc="评论列表id")
     * @Apidoc\Param("status",type="string",require=true,desc="wait待审核；pass通过；refuse未通过")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function commentStatusUpdate(Request $request ,DynamicService $dynamicService)
    {
        $params = $request->input();
        $result = $dynamicService->updateCommentStatus($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("客户详情-删除评论")
     * @Apidoc\Url("/agency/commentDel")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("ids",type="int",require=true,desc="评论列表id")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function commentDel(Request $request ,DynamicService $dynamicService)
    {
        $params = $request->input();
        $result = $dynamicService->commentDel($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("动态广场-动态列表")
     * @Apidoc\Url("/agency/getDynamicList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",desc="页数")
     * @Apidoc\Param("pageSize",type="int",desc="每页条数")
     * @Apidoc\Param("mid",type="int",desc="用户id")
     * @Apidoc\Param("username",type="string",desc="用户昵称")
     * @Apidoc\Param("mobile",type="string",desc="用户手机号")
     * @Apidoc\Param("content",type="string",desc="动态内容")
     * @Apidoc\Param("status",type="string",desc="动态状态")
     * @Apidoc\Returned("id",type="int",desc="动态id")
     * @Apidoc\Returned("mid",type="int",desc="发布者id")
     * @Apidoc\Returned("content",type="string",desc="动态内容")
     * @Apidoc\Returned("status",type="string",desc="动态状态")
     * @Apidoc\Returned("created_at",type="object",desc="发布时间")
     * @Apidoc\Returned("imgs",type="array",desc="动态图片数组")
     * @Apidoc\Returned("base",type="object",desc="动态发布用户基本信息")
     * @Apidoc\Returned("comment",type="array",desc="动态评论数组",children={
     *      @Apidoc\Returned("id",type="string",desc="动态id"),
     *      @Apidoc\Returned("mid",type="string",desc="评论者id"),
     *      @Apidoc\Returned("content",type="string",desc="评论内容"),
     *      @Apidoc\Returned("zans",type="string",desc="评论点赞数"),
     *      @Apidoc\Returned("status",type="string",desc="评论状态"),
     *      @Apidoc\Returned("created_at",type="string",desc="评论发布时间"),
     *     @Apidoc\Returned("base",type="object",desc="评论用户基本信息"),
     * })
     *
     */
    public function getDynamicList(Request $request ,DynamicService $dynamicService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $dynamicService->getDynamicList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("动态广场-评论列表")
     * @Apidoc\Url("/agency/getCommentList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",desc="页数")
     * @Apidoc\Param("pageSize",type="int",desc="每页条数")
     * @Apidoc\Param("mid",type="int",desc="用户id")
     * @Apidoc\Param("username",type="string",desc="用户昵称")
     * @Apidoc\Param("mobile",type="string",desc="用户手机号")
     * @Apidoc\Param("content",type="string",desc="评论内容")
     * @Apidoc\Param("status",type="string",desc="评论状态")
     * @Apidoc\Returned("id",type="int",desc="评论id")
     * @Apidoc\Returned("mid",type="int",desc="发布者id")
     * @Apidoc\Returned("content",type="string",desc="评论内容")
     * @Apidoc\Returned("status",type="string",desc="评论状态")
     * @Apidoc\Returned("created_at",type="object",desc="发布时间")
     * @Apidoc\Returned("base",type="object",desc="评论发布用户基本信息")
     * @Apidoc\Returned("obase",type="object",desc="动态发布用户基本信息")
     */
    public function getCommentList(Request $request ,DynamicService $dynamicService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $dynamicService->getCommentList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("动态广场-点赞列表")
     * @Apidoc\Url("/agency/getDynamicZanList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",desc="页数")
     * @Apidoc\Param("pageSize",type="int",desc="每页条数")
     * @Apidoc\Param("mid",type="int",desc="用户id")
     * @Apidoc\Param("username",type="string",desc="用户昵称")
     * @Apidoc\Returned("id",type="int",desc="点赞id")
     * @Apidoc\Returned("mid",type="int",desc="点赞者id")
     * @Apidoc\Returned("content",type="string",desc="动态内容")
     * @Apidoc\Returned("imgs",type="array",desc="动态图片数组")
     * @Apidoc\Returned("created_at",type="object",desc="点赞时间")
     * @Apidoc\Returned("base",type="object",desc="点赞用户基本信息")
     * @Apidoc\Returned("obase",type="object",desc="动态发布用户基本信息")
     */
    public function getDynamicZanList(Request $request ,DynamicService $dynamicService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $dynamicService->getDynamicZanList($params);
        return $this->responseSuccess($result);
    }
}
